package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2022-08-23
 * Time: 22:04
 * name： 归还图书操作
 */
public class ReturnOperation implements IOperation{

    @Override
    public void way(BookList bookList) {
        System.out.println("归还图书! ");
        System.out.println("请输入要归还得图书名字：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();

        for (int i = 0; i < bookList.getCountsize(); i++) {
            Book book = bookList.getpos(i);
            if (name.equals(book.getName())) {
                book.setBorrow(false);
                System.out.println("归还成功!");
                return;
            }
        }
        System.out.println("系统中无此书！");
    }
}
